﻿@model MvcCmsOptIn.Models.OptInModel 
@section HtmlHead{
    <link href="@Url.Content("/RazorThemes/" + Model._Portal.SkinName + "/css/optin.css")" rel="stylesheet" type="text/css" />
}
<div class="contentpage-outerdiv">
    <div id="container">
        <div class="breadcrumb">
            <span><a href="/optin-manager">Main Menu</a></span><span>» </span><span><a href="/optin-manager/subscribers">
                Subscribers</a></span><span>» </span><span>Import</span>
        </div>
        <div class="optin-content">
            <h1>
                Import Subscribers From @Model._Portal.DisplayName</h1>
            <div>
                By clicking the link below all users from @Model._Portal.Name that have not been added to the 
                subscribers list will be added.  Email addresses added to the subscriber list but that have opted for 
                do not contact still show up on the Subscribers page until deleted but will not get email from any
                list they may be on.     
                <div class="importer-container">
                    <div>
                        <label for"Roles">Roles (comma seperated) ~ (leave blank to retrieve all roles)</label>
                        @Html.TextBox("Roles", "")
                    </div>
                    <div>
                        List(s) To Add Imported Users To:
                        @foreach (var list in Model._Lists)
                        {
                            <div>@Html.CheckBox(list.ListName, false, new {listId=list.ListID}) @list.ListName</div>
                        }
                    </div>
                    <div style="float:left; width:260px;">
                        <a href="javascript:void(0);" onclick="ImportSiteUsers();">
                            <img alt="batch import" border="0" src="/areas/mvccmsoptin/content/buttons/batch.gif" /> 
                        </a>      Click Icon To Begin Import               
                    </div>
                    <div style="float:left; width:80px;">
                        <img border="0" id="busy" style="display:none;" src="/content/images/busy.gif" />
                        <span id="result"></span>
                    </div>
                    <div style="clear:both;"></div>
                </div>           
            </div>
        </div>
    </div>
</div>
@section ScriptContent{
<script id="General" type="text/javascript">
    function ImportSiteUsers() {
        $("#busy").show();
        var listIds = new Array()
        jQuery("input:checkbox:checked").each(function () {
            var listId = $(this).attr("listId");
            listIds.push(listId);
        });
        jQuery.ajaxSettings.traditional = true;
        $.post("/optinajax/importsubscribersfromportal",
        {Roles:$("#Roles").val(), ListIds:listIds},
	    function (data) {
	        var objdata = data;
	        if (objdata.error) {
	            //alert(objdata.error);
	        }
	        else {
	            $("#result").text(objdata.result);
	            $("#busy").hide();
	        }
	    }, "json");        
    }

    $(document).ready(function() {

    });
</script>
}
@section SideBar{
}

